package com.zz.io;

import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;

public class Test5 {
    public static void main(String args[]){
        try ( //覆盖管道
//                Writer w = new FileWriter("opp-app1\\src\\data\\test2.txt");
              //追加管道
              Writer w = new FileWriter("opp-app1\\src\\data\\test2.txt", true);
        ) {
            //1.public void write(int c)：写一个字符出去
            w.write('a');
            w.write(89);
            w.write("国");

            //2.public void write(String c)写一个字符串进去
            w.write("我爱你中国");

            //3.public void write(String c, int pos, int len)写字符串的一部分
            w.write("祖国繁荣昌盛", 2, 4);

            w.write("\r\n");

            //public void write(char[] buffer);写一个字符数组
            char buffer[] = {'永', '远', '自', '由'};
            w.write(buffer);

        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
